﻿<Window x:Class="AppToolkit.WPF.Tests.UI.Search.SearchWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:AppToolkit.WPF.Tests.UI.Search"
        xmlns:cnv="clr-namespace:AppToolkit.WPF.UI.Converters;assembly=AppToolkit.WPF"
        Title="SearchWindow" Height="300" Width="300">
    <Grid>
        <Grid.Resources>
            <cnv:BoolToVisiblityConverter x:Key="boolToVisibilityConverter" />
            <local:ErrorInfoConverter x:Key="errorInfoConverter" />

            <Style x:Key="textStyleTextBox" TargetType="TextBox">
                <Setter Property="Foreground" Value="#333333" />
                <Setter Property="MaxLength" Value="40" />
                <Setter Property="Width" Value="392" />
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="true">
                        <Setter Property="ToolTip" Value="{Binding SearchContext.HasError,Converter={StaticResource errorInfoConverter}}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>

        </Grid.Resources>

        <TextBox Height="23" HorizontalAlignment="Left" Name="txtSearch" VerticalAlignment="Top" Width="169"
                 Style="{StaticResource textStyleTextBox}">
            <TextBox.Text>
                <Binding Path="SearchContext.SearchSpecification" UpdateSourceTrigger="PropertyChanged">
                </Binding>
            </TextBox.Text>
            <TextBox.InputBindings>
                <KeyBinding Gesture="ESC" Command="{Binding Path=SearchContext.ResetCommand}" />
                <KeyBinding Gesture="F3" Modifiers="SHIFT" Command="{Binding Path=SearchContext.SearchPrevCommand}" />
                <KeyBinding Gesture="F3" Command="{Binding Path=SearchContext.SearchNextCommand}" />
                <KeyBinding Gesture="Enter" Command="{Binding Path=SearchContext.SearchNextCommand}" />
            </TextBox.InputBindings>
        </TextBox>
        <Button Content="Search" Height="23" HorizontalAlignment="Left" Margin="203,0,0,0" Name="btnSearch"
                VerticalAlignment="Top" Width="75" Command="{Binding SearchContext.SearchNextCommand}" />
        <ListBox Height="232" HorizontalAlignment="Left" Margin="0,29,0,0" Name="lstCollection"
                  VerticalAlignment="Top" Width="278" ItemsSource="{Binding View}" IsSynchronizedWithCurrentItem="True" />
        <Label Content="!" Height="23" HorizontalAlignment="Left" Margin="175,0,0,0" Name="lblError" VerticalAlignment="Top" Width="22" FontWeight="Bold" FontSize="16" HorizontalContentAlignment="Center" Padding="0" Foreground="Crimson"
               Visibility="{Binding SearchContext.HasError,Converter={StaticResource boolToVisibilityConverter}}"
               ToolTip="{Binding SearchContext.ErrorInfo,Converter={StaticResource errorInfoConverter}}">
        </Label>
    </Grid>
</Window>